<?php html::pushHead('user/1.css')?>
<div class="operateBox">
  <div id="p_toolbar"></div>
  <h2><?php echo $this->title?></h2> 
</div>

<form id="u_form" method="post" action="" class="post-tr tabB">
  <input type="hidden" id="data_id" name="data_id" value="<?php echo $data['id'];?>" />
  
  <ul class="tabTitleB" id="groupList">
    <li class="tab-t">基本信息</li>
    <li class="tab-t">详细资料</li>
    <li class="tab-t">预约设置</li>
  </ul>
  
  <div class="tab-c">
    <span class="sh">帐号：</span>
    <span class="sp"><input type="text" name="data[name]" value="<?php e_h($data['name'])?>" /></span>
    <span class="sh">密码：</span>
    <span class="sp"><input type="text" name="data[password]" <?php if($data['id'])echo 'placeholder="留空不修改"';?> />
                      <a class="p-browseBut" onclick="crePassword($(this).siblings('input')[0],6);"><?php lang::_g('auto create')?></a></span>
    <span class="sh">邮箱：</span>
    <span class="sp"><input type="text" class="update" name="data[email]" value="<?php e_h($data['email'])?>" /></span>
    <span class="sh">级别：</span>
    <span class="sp"><?php html::selectR('name="data[grade_id]"', YF_f::initC('\c\user\grade')->get(), $data['grade_id'], null)?></span>
    <span class="sh">状态：</span>
    <span class="sp"><?php html::radio('name="data[state]"', lang::Ag($this->State), $data['state'])?></span>


    <?php $gR = array();if($AG = $this->PU->check('auth_group', 're')){ $gR = YF_f::initC('\c\auth\group')->get(); ?>
    <div class="separator"></div>
    <span class="sh">权限组：</span>
    <span class="sp"><?php html::checkboxR('name="data[au_group_ids][]"', $gR, $data['au_group_ids'], null, null, '<br />')?></span>
    <?php }?>
  </div>
  <div class="tab-c">
  	<span class="sh">姓名：</span>
    <span class="sp"><input type="text" class="update" name="data[compellation]" value="<?php e_h($data['compellation'])?>" /></span>
    <span class="sh">性别：</span>
    <span class="sp"><?php html::radioName(' name="data[sex]"', lang::Ag(array('boy','gril')), $data['sex'])?></span>
    <span class="sh">出生日期：</span>
    <span class="sp"><input type="text" name="data[birthdate]" value="<?php e_h($data['birthdate'])?>" onclick="WdatePicker();" class="Wdate" size="12" /></span>
    <span class="sh">头像：</span>
    <span class="sp"><input type="text" name="data[pic]" value="<?php e_h($data['pic'])?>" id="p_pic" />
    				<a class="p-browseBut" onclick="openFileWin('set_obj=p_pic&set_val=id');"><?php lang::_g('browse')?></a></span>
    <span class="sh">手机号码：</span>
    <span class="sp"><input type="text" class="update" name="data[phone]" value="<?php e_h($data['phone'])?>" /></span>
    
    <div class="separator"></div>
    <span class="sh">推荐人：</span>
    <span class="sp"><input type="text" name="data[parent_id]" value="<?php if($data['parent_id'])e_h(Yf_f::initC('\c\user\g')->getName($data['parent_id']))?>" /></span>
  </div>
  <div class="tab-c">
	<span class="sh">生效日期：</span>
    <span class="sp"><input type="text" name="expiry[date]" onclick="WdatePicker();" value="<?php e_h($data['expiry']['date'])?>"  /></span>
    <span class="sh">权限组：</span>
    <span class="sp">
            <?php if($gR) html::checkboxR('name="expiry[per_group_ids][]"', $gR, $data['expiry']['per_group_ids'], null, null, '<br />')?>
            <i class="textNote">不设置权限组则禁用账号</i></span>
  </div>
</form>

<script type="text/javascript">
tabs();
if ($('#data_id').val())
	post_updatedField('#u_form');
	
Toolbar.init('#p_toolbar')
  .addBut('checkin', function(){save_D('checkin')})
  .addBut('save', function(){save_D()})
  .addBut('save_new', function(){save_D('save_new')});
function save_D(b){
  if(!CheckForm('u_form')) return;
  var bx = box(language._('bao cun zhong')),f=$('#u_form'), c_U='?u=cuser\\a'; 
  $.post( c_U +'-fsave', f.serialize(), function(res){
	if (!checAjaxRe(res))
		return bx.close();
	bx.set(language._('OK')).close(0.6);
	if (b=='save_new')
		$('#data_id').val() ? document.location.href = c_U+'-fpost' : f[0].reset();
	else{
		$('#data_id').val(res.id);
		if(b=='checkin'){  window.opener ? window.close() : document.location.href = c_U;}
	}	
  });
}
</script>